package com.qf.web.servlet;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

/**
 * @author 千锋教育
 * @Company http://www.mobiletrain.org/
 * @Version 1.0
 */
@WebServlet("/testServlet")
public class TestServlet extends BaseServlet {
    public void select(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp){
        System.out.println("add");
        try {
            resp.getWriter().print("ajax");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String add(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp){
        System.out.println("add");
        return "redirect:/login.jsp";
    }

    public String update(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp){
        System.out.println("update");
        return "forward:/login.jsp";
    }
//    @Override
//    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        doPost(req, resp);
//    }
//
//    @Override
//    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        String id = req.getParameter("id");
//        System.out.println(id);
//
//        //响应前端（转发与重定向）
////        resp.sendRedirect("/login.jsp");
////        req.getRequestDispatcher("/login.jsp").forward(req , resp);
//
//        //如果前端是ajax
//        resp.setCharacterEncoding("utf-8");
//        resp.setContentType("text/html;charset=utf-8");
//        resp.getWriter().print("这是我的仿小米 商城");
//    }
}
